/***************************************************************
 *  Copyright (c) 2007 by GroupMe! Team (www.groupme.net)
 *  All rights reserved
 *
 *  This file is part of the GroupMe! Project. You can utilize
 *  software of the GroupMe! project under the terms of the 
 *  GNU Lesser General Public License as published by the
 *  Free Software Foundation in version 2.1.
 * 
 *  The GNU Lesser General Public License can be found at:
 *  http://www.gnu.org/licenses/lgpl.html
 *
 *  This copyright notice MUST APPEAR in all copies of the file!
 ***************************************************************/
package net.groupme.model;

import java.net.URI;
import java.util.Collection;
import java.sql.Date;

import net.groupme.exceptions.DeleteFailedException;
import net.groupme.exceptions.InsertFailedException;
import net.groupme.exceptions.UpdateFailedException;
import net.groupme.model.dao.TagDAO;

/**
 * 
 * This class implements the Tag object {@link net.groupme.model.Tag} for the
 * GroupMe! project.
 * 
 * @author Mischa Frank <a
 *         href="mailto:code@planetfrank.net">code@planetfrank.net</a>
 * 
 * @version 1.0, created on 30.04.2007
 * 
 */
public class TagImpl implements Tag {

	private TagDAO tagDAO = null;

	public TagImpl(TagDAO tagDAO) {
		this.tagDAO = tagDAO;
	}

	/* (non-Javadoc)
	 * @see net.groupme.model.Identifiable#getId()
	 */
	public String getId() {
		return this.tagDAO.getId();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see net.groupme.model.Tag#add(net.groupme.model.Resource,
	 *      net.groupme.model.User, net.groupme.model.Group, java.sql.Date,
	 *      double)
	 */
	public void add(Resource resource, User user, Group group, Date date,
			double importance) throws InsertFailedException {
		this.tagDAO.add(resource, user, group, date, importance);
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object otherTag) {
		if(otherTag instanceof Tag){
			return this.getId().equals(((Tag)otherTag).getId());
		}
		return false;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see net.groupme.model.Identifiable#getDescription()
	 */
	public String getDescription() {
		return this.tagDAO.getDescription();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see net.groupme.model.Tag#getKeyword()
	 */
	public String getKeyword() {
		return this.tagDAO.getKeyword();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see net.groupme.model.Identifiable#getLabel()
	 */
	public String getLabel() {
		return this.tagDAO.getLabel();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see net.groupme.model.Tag#getResources()
	 */
	public Collection<Resource> getResources() {
		return this.tagDAO.getResources();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see net.groupme.model.Tag#getResources(net.groupme.model.User)
	 */
	public Collection<Resource> getResources(User tagger) {
		return this.tagDAO.getResources(tagger);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see net.groupme.model.Tag#getResources(net.groupme.model.User,
	 *      net.groupme.model.Group)
	 */
	public Collection<Resource> getResources(User user, Group group) {
		return this.tagDAO.getResources(user, group);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see net.groupme.model.Identifiable#getURI()
	 */
	public URI getURI() {
		return this.tagDAO.getURI();
	}

	/* (non-Javadoc)
	 * @see net.groupme.model.Tag#getUsers(net.groupme.model.Resource)
	 */
	public Collection<User> getUsers(Resource resource) {
		return this.tagDAO.getUsers(resource);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see net.groupme.model.Tag#remove(net.groupme.model.Resource,
	 *      net.groupme.model.User, net.groupme.model.Group)
	 */
	public void remove(Resource resource, User user, Group group)
			throws DeleteFailedException {
		this.tagDAO.remove(resource, user, group);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see net.groupme.model.Identifiable#setDescription(java.lang.String)
	 */
	public void setDescription(String description) throws UpdateFailedException {
		this.tagDAO.setDescription(description);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see net.groupme.model.Tag#setKeyword(java.lang.String)
	 */
	public void setKeyword(String keyword) throws UpdateFailedException {
		this.tagDAO.setKeyword(keyword);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see net.groupme.model.Identifiable#setLabel(java.lang.String)
	 */
	public void setLabel(String label) {
		this.tagDAO.setLabel(label);
	}
}
